package com.looptext;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String inputString = sc.nextLine();
//sc.has
        System.out.println(isloop(inputString));
    }

    public static boolean isloop(String text) {
        char[] textArray = text.toCharArray();
        int length = textArray.length;

        boolean isloop = true; // 默认是回文
        for(int i=0; i<=length-1; i++) {
            char string1 = textArray[i];
            char string2 = textArray[length-1-i];
            if(length-1-2*i <= 1) { // 如果两个索引相差小于等于1 说明比较完毕
                break;
            }
            if(string1 != string2) { // 如果两个循环位不相等 就说明不是回文
                isloop = false;
                break;
            }
        }
        return isloop;
    }
}